<?php
namespace app\manager\model;

use think\Model;
use app\common\traits\model\TraitModel;

class Cards extends Model
{
    use TraitModel;
    protected $table = 'cards';

    public function getStatusAttr($value)
    {
        $status = [0=>'未绑定',1=>'已绑定'];
        return $status[$value];
    }

    public function camps()
    {
    	return $this->belongsTo('Camps','services');
    }

    public function caravans()
    {
    	return $this->belongsTo('Caravans','caravan_id');
    }

    public function createCards($post_card_info)
    {
        return $this->create($post_card_info);
    }

    public function getCardLists($querys = [])
    {
        $id = session('manager.id');
        $camp_id = model('CampManagers')->where('id',$id)->value('camp_id');
        $querys = array_merge($querys,['camp_id' => $camp_id]);
        return $this->getInfoList($querys);
    }

    public function getCardInfo($id)
    {
        return $this->where('id',$id)->find();
    }
	
	/**
	 * 总公司获取全部卡号
	 */
	public function getAllCardLists($querys = []){
		return $this -> getInfoList($querys);		
	}	 
}